/**
 * 
 */
package cz.cvut.fit.crhonjar.mi.paa.dunedin.solver;

import java.util.Comparator;
import java.util.PriorityQueue;

import cz.cvut.fit.crhonjar.mi.paa.dunedin.Bucket;
import cz.cvut.fit.crhonjar.mi.paa.dunedin.State;

/**
 * @author Jarec
 * 
 */
public class SquareOfDistanceFromFinalSolver extends Solver {

	@Override
	public void initializeQue() {
		final Comparator<State> c = new Comparator<State>() {

			@Override
			public int compare(final State s1, final State s2) {
				int distance1 = 0;
				int distance2 = 0;
				for (final Bucket b : s1.getBuckets()) {
					int tmp = b.getFinalVolume() - b.getActual();
					tmp *= tmp;
					distance1 += tmp;
				}

				for (final Bucket b : s2.getBuckets()) {
					int tmp = b.getFinalVolume() - b.getActual();
					tmp *= tmp;
					distance2 += tmp;
				}
				return (int) (Math.sqrt(distance1) - Math.sqrt(distance2));
			}

		};
		this.que = new PriorityQueue<State>(1024, c);
	}

}
